firststrikemodfandomcom-20200214-history
Template talk:Vehicle Infobox
Infobox Technical Info I know the wiki behind this Vehicle Infobox may be a bit confusing at first glance, so here's a breakdown of what's happening... The Table Rows The infobox is quite simply a table. A pipe character ("|") marks the different sections, and a pipe with a dash ("|-") marks the beginning of each row. This table is arranged like so... ::' ' The If We want some rows to be optional. That is, to make them only appear if data was actually put in them. To achieve this, we use the #if function. It's pretty simple to learn: :: ::-or- :: Table Row + If In our case, we simply go "if parameter-is-not-blank, then show its row". So the result will resemble... :: } | ::|- ::| row format | row data ::}} ...repeating on all the rows that we want to be optional. The Extra-Line Problem Unfortunately that last arrangement produces a slight bug. The new-row marker "|-" must be at the beginning of its own paragraph (as seen in the example above). So normally you would type it like " } |" and hit Enter to start a new paragraph, then write "|-". However, the If command notices the new paragraph change, and occasionally it will make an extra line. More importantly, since it's making it just before reaching the new-row marker, it adds the line to the last created cell. This bug does not always appear, but it happens quite often when two or more rows were not filled in and so hidden. Example: }}| - Row #2 }} }| - Row #3 }} - style="text-align:center; background:#f0f0f0; color:#000000; border-top: 1px solid #999; border-bottom: 1px solid #999;" Row #4 }} |} The Solution Since the unwanted line appears when "If" is placed before the new-row marker, the solution is simply this: place the marker before the "If" line instead. ::|- (one is placed at start of wiki) :: } | ::| row format | row data ::|- ::}} ...repeating the latter-section on all the rows that we want to be optional. In other words, instead of putting the marker just before the row-data, we put it right afterwards, so it can help the next row. We also add a marker at the very beginning of the table to start if all off. Why? Because any extra spaces just after a marker bar would have no purpose, the row formatting hasn't even been started! So the wiki simply ignores them. Don't worry about it placing an extra "|-" at the end, blank rows are ignored as well. The Pipe Characters You may have noticed that both Tables and If commands use pipe characters ("|") to separate their different parts. But if you put an If inside a Table, how do they discern what info's meant for who? The sad truth is, they don't. Any row markers you put within an If command will NOT be read by the table. To solve this, the template was created, with a single | pipe character put in it. So when you type the phrase " ", the table will read it as pipe character and act accordingly, but the thankfully less-smart If command will ignore it completely. The end result should resemble this... ::|- (one is placed at start of wiki) :: } | :: row format row data :: - ::}} The solution and more details about it can be found at this link: http://en.wikipedia.org/wiki/Wikipedia:Conditional_tables#Plan_B Table Comments Naturally a long infobox table will seem a little hard to get around, so to make it easier to discern the rows, comment lines can be added. Here is a simple example... ::' ::'|- ::| colspan=2 style="background: #313233;" | ''' } ::' ::'|- ::| colspan=2 style="background: #313233;" | ''' } Credits Scary stuff, eh? Not really, once you understand the general ideas. I hope you found this little guide helpful, but it was thanks to these articles that the infobox was finalized at all: Wikipedia:Help:Table m:Help:ParserFunctions#.23if: Wikipedia:Wikipedia:Conditional_tables#Plan_B And much thanks to Gamerwiz and his work with LiveWiki for making this infobox and maintaining it. ShadowfaxSTF 06:20, 12 October 2007 (UTC)